/*
package com.friends.utils.trace;

import com.xinyuan.common.logger.context.LoggerContextHolder;
import com.xinyuan.common.logger.context.RecordChangeContextHolder;
import com.xinyuan.context.LoginUserHolder;
import com.xinyuan.context.TenantContextCoreHolder;
import com.xinyuan.core.common.util.token.TokenUtils;
import com.xinyuan.mvc.vo.ContextUserInfo;
import com.xinyuan.mvc.vo.LoginDynamicInfo;
import com.xinyuan.mvc.vo.Visit;
import com.xinyuan.security.constants.TenantConstans;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import com.xinyuan.common.logger.Logger;
import com.xinyuan.common.logger.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

*/
/**
 * 声明为spring的bean即生效
 *//*

@Component
public class FeignInterceptor implements RequestInterceptor {
    private Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    public static final String TOKEN_USERINFO_HEADER_NAME = "user-info";
    public static final String TOKEN_INFO_NAME = "token-info";
    public static final String USERID_HEADER_NAME = "user-id";
    @Override
    public void apply(RequestTemplate requestTemplate) {
        //String tenant = TenantContextCoreHolder.getTenant();
        //this.logger.debug("微服务场景：租户id传递tenant-id={}", tenant);
        TenantContextCoreHolder.DomainInfo domainInfo =  TenantContextCoreHolder.getDomainInfo();
        if (domainInfo != null) {
            String tenant = domainInfo.getCustomize_id();
            this.logger.debug("微服务场景：租户id传递tenant-id={}", tenant);
            if (StringUtils.hasText(tenant)) {
                requestTemplate.header(TenantConstans.KEY_TENANT_ID, tenant);
            }
        }

        String traceId = LoggerContextHolder.getTraceId();
        this.logger.debug("微服务场景：traceId传递traceId={}", traceId);
        if (StringUtils.hasText(traceId)) {
            requestTemplate.header(LoggerContextHolder.LOGGER_CONTEXT_TRACE_ID_HEADER_NAME, traceId);
        }
        String pspanId = LoggerContextHolder.getSpanId();
        this.logger.debug("微服务场景：pspanId传递pspanId={}", pspanId);
        if (StringUtils.hasText(pspanId)) {
            requestTemplate.header(LoggerContextHolder.LOGGER_CONTEXT_PSPAN_ID_HEADER_NAME, pspanId);
        }
        String loggerRecordChange = RecordChangeContextHolder.getRecordDB()==null?"false" : RecordChangeContextHolder.getRecordDB().toString();
        this.logger.debug("rest场景：logger-record-change传递logger-record-change={}", loggerRecordChange);
        if (com.xinyuan.core.common.util.StringUtils.isNotBlank(loggerRecordChange)) {
            requestTemplate.header(RecordChangeContextHolder.LOGGER_CONTEXT_RECORD_CHANGE_NAME, loggerRecordChange);
        }
        ContextUserInfo contextUserInfo = LoginUserHolder.get();
        //String dlh = null, token = null, userId = null;
        //2024-01-10移除登录号
        String token = null, userId = null;
        if (contextUserInfo != null) {
            Visit visit = contextUserInfo.getVisit();
            if (visit != null) {
                //dlh = visit.getDlh();
                userId = visit.getId();
            }
            LoginDynamicInfo loginDynamicInfo = contextUserInfo.getLoginDynamicInfo();
            if (loginDynamicInfo != null) {
                token = loginDynamicInfo.getAccessToken().getTokenValue();
            }
        }
        //this.logger.debug("微服务场景：传递用户登录号:{}", dlh);
        this.logger.debug("微服务场景：传递用户token:{}", token);
        this.logger.debug("微服务场景：传递用户id:{}", userId);
        */
/*if (StringUtils.hasText(dlh)) {
            requestTemplate.header(TOKEN_USERINFO_HEADER_NAME, dlh);
        }*//*

        if (StringUtils.hasText(token)) {
            requestTemplate.header(TOKEN_INFO_NAME, token);
        }
        if (StringUtils.hasText(userId)) {
            requestTemplate.header(USERID_HEADER_NAME, userId);
        }

        requestTemplate.header("token", TokenUtils.createToken());
    }
}
*/
